<template>
  <div class="page_search search_index">
	<div class="warp">
	  <div class="container">
		<div class="row">
		  <div class="col-12">
			<div class="card_result_search">
			  <div class="title">搜索结果</div>
				<!-- 商品搜索结果 -->
			  <list_result_search
				:list="result_goods"
				title="器材商城"
				source_table="goods"
			  ></list_result_search>



						  <list_result_search
				v-if="$check_action('/member_user/list', 'get')"
				:list="result_member_user_user_name"
				title="会员用户用户姓名"
				source_table="member_user"
			  ></list_result_search>
															  <list_result_search
				v-if="$check_action('/business_user/list', 'get')"
				:list="result_business_user_business_name"
				title="商家用户商家姓名"
				source_table="business_user"
			  ></list_result_search>
															  <list_result_search
				v-if="$check_action('/crowd_type/list', 'get')"
				:list="result_crowd_type_crowd_type"
				title="人群类型人群类型"
				source_table="crowd_type"
			  ></list_result_search>
									  <list_result_search
				v-if="$check_action('/equipment_mall/list', 'get')"
				:list="result_equipment_mall_applicable_crowd"
				title="器材商城‌适用人群"
				source_table="equipment_mall"
			  ></list_result_search>
																		  <list_result_search
				v-if="$check_action('/business_type/list', 'get')"
				:list="result_business_type_business_type"
				title="经营类型经营类型"
				source_table="business_type"
			  ></list_result_search>
									  <list_result_search
				v-if="$check_action('/store_information/list', 'get')"
				:list="result_store_information_shop_name"
				title="店铺信息店铺名称"
				source_table="store_information"
			  ></list_result_search>
											  <list_result_search
				v-if="$check_action('/store_information/list', 'get')"
				:list="result_store_information_business_scope"
				title="店铺信息经营范围"
				source_table="store_information"
			  ></list_result_search>
																								  <list_result_search
				v-if="$check_action('/trial_appointment/list', 'get')"
				:list="result_trial_appointment_shop_name"
				title="试用预约店铺名称"
				source_table="trial_appointment"
			  ></list_result_search>
																																										  <list_result_search
				v-if="$check_action('/maintenance_appointment/list', 'get')"
				:list="result_maintenance_appointment_shop_name"
				title="维修预约店铺名称"
				source_table="maintenance_appointment"
			  ></list_result_search>
																																							</div>
		  </div>
		</div>
	  </div>
	</div>
  </div>
</template>

<script>
import mixin from "../../mixins/page.js";
import list_result_search from "../../components/diy/list_result_search.vue";

export default {
  mixins: [mixin],
  data() {
	return {
	  "query": {
		word: "",
	  },
	  "result_goods": [],
						"result_member_user_user_name":[],
															"result_business_user_business_name":[],
															"result_crowd_type_crowd_type":[],
									"result_equipment_mall_applicable_crowd":[],
																		"result_business_type_business_type":[],
									"result_store_information_shop_name":[],
											"result_store_information_business_scope":[],
																								"result_trial_appointment_shop_name":[],
																																										"result_maintenance_appointment_shop_name":[],
																																					};
  },
  methods: {
	/**
	 * 获取${fmodel.filter.cart_name}
	 */
	get_goods() {
	  this.$get("~/api/goods/get_list?like=0", { page: 1, size: 10, title: this.query.word }, (json) => {
		if (json.result) {
		  this.result_goods = json.result.list;
		}
	  });
	},

				/**
	 * 获取user_name
	 */
	get_member_user_user_name(){
		let url = "~/api/member_user/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "user_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_member_user_user_name = json.result.list;
			result_member_user_user_name.map(o => o.title = o['user_name'])
	  			this.result_member_user_user_name = result_member_user_user_name
		 	}
		});
	},
													/**
	 * 获取business_name
	 */
	get_business_user_business_name(){
		let url = "~/api/business_user/get_list?like=0";
				url = url+"&examine_state=已通过";
				this.$get(url, { page: 1, size: 10, "business_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_business_user_business_name = json.result.list;
			result_business_user_business_name.map(o => o.title = o['business_name'])
	  			this.result_business_user_business_name = result_business_user_business_name
		 	}
		});
	},
													/**
	 * 获取crowd_type
	 */
	get_crowd_type_crowd_type(){
		let url = "~/api/crowd_type/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "crowd_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_crowd_type_crowd_type = json.result.list;
			result_crowd_type_crowd_type.map(o => o.title = o['crowd_type'])
	  			this.result_crowd_type_crowd_type = result_crowd_type_crowd_type
		 	}
		});
	},
							/**
	 * 获取applicable_crowd
	 */
	get_equipment_mall_applicable_crowd(){
		let url = "~/api/equipment_mall/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "applicable_crowd": this.query.word }, (json) => {
		  if (json.result) {
			var result_equipment_mall_applicable_crowd = json.result.list;
			result_equipment_mall_applicable_crowd.map(o => o.title = o['applicable_crowd'])
	  			this.result_equipment_mall_applicable_crowd = result_equipment_mall_applicable_crowd
		 	}
		});
	},
																/**
	 * 获取business_type
	 */
	get_business_type_business_type(){
		let url = "~/api/business_type/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "business_type": this.query.word }, (json) => {
		  if (json.result) {
			var result_business_type_business_type = json.result.list;
			result_business_type_business_type.map(o => o.title = o['business_type'])
	  			this.result_business_type_business_type = result_business_type_business_type
		 	}
		});
	},
							/**
	 * 获取shop_name
	 */
	get_store_information_shop_name(){
		let url = "~/api/store_information/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "shop_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_store_information_shop_name = json.result.list;
			result_store_information_shop_name.map(o => o.title = o['shop_name'])
	  			this.result_store_information_shop_name = result_store_information_shop_name
		 	}
		});
	},
									/**
	 * 获取business_scope
	 */
	get_store_information_business_scope(){
		let url = "~/api/store_information/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "business_scope": this.query.word }, (json) => {
		  if (json.result) {
			var result_store_information_business_scope = json.result.list;
			result_store_information_business_scope.map(o => o.title = o['business_scope'])
	  			this.result_store_information_business_scope = result_store_information_business_scope
		 	}
		});
	},
																						/**
	 * 获取shop_name
	 */
	get_trial_appointment_shop_name(){
		let url = "~/api/trial_appointment/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "shop_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_trial_appointment_shop_name = json.result.list;
			result_trial_appointment_shop_name.map(o => o.title = o['shop_name'])
	  			this.result_trial_appointment_shop_name = result_trial_appointment_shop_name
		 	}
		});
	},
																																								/**
	 * 获取shop_name
	 */
	get_maintenance_appointment_shop_name(){
		let url = "~/api/maintenance_appointment/get_list?like=0";
				this.$get(url, { page: 1, size: 10, "shop_name": this.query.word }, (json) => {
		  if (json.result) {
			var result_maintenance_appointment_shop_name = json.result.list;
			result_maintenance_appointment_shop_name.map(o => o.title = o['shop_name'])
	  			this.result_maintenance_appointment_shop_name = result_maintenance_appointment_shop_name
		 	}
		});
	},
																																				
  },
  components: { list_result_search },
	created(){
    this.query.word = this.$route.query.word || "";
  },
  mounted() {
	this.get_goods();
					this.get_member_user_user_name();
														this.get_business_user_business_name();
														this.get_crowd_type_crowd_type();
								this.get_equipment_mall_applicable_crowd();
																	this.get_business_type_business_type();
								this.get_store_information_shop_name();
										this.get_store_information_business_scope();
																							this.get_trial_appointment_shop_name();
																																									this.get_maintenance_appointment_shop_name();
																																				  },
  watch: {
	$route() {
	  $.push(this.query, this.$route.query);
	  this.get_goods();
				  this.get_member_user_user_name();
													  this.get_business_user_business_name();
													  this.get_crowd_type_crowd_type();
							  this.get_equipment_mall_applicable_crowd();
																  this.get_business_type_business_type();
							  this.get_store_information_shop_name();
									  this.get_store_information_business_scope();
																						  this.get_trial_appointment_shop_name();
																																								  this.get_maintenance_appointment_shop_name();
																																					},
  },
};
</script>

<style scoped>
.card_search {
  text-align: center;
}
.card_result_search>.title {
  text-align: center;
  padding: 10px 0;
}
</style>
